package seis;

import java.util.Scanner;

public class Romano {
	

		public static void main(String args[]) {
			int x, i;
			int Vn[] = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
			String Vc[] = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX",
					"V", "IV", "I" };
			
			System.out.println("ingrese un numero entre 1 y 9999");
			Scanner in = new Scanner(System.in);
			while (true) {
				x = in.nextInt();
				if (x == 0)
					break;
				System.out.printf("%-4d ", x);
				i = 0;
				while (x > 0) {
					if (x >= Vn[i]) {
						System.out.print(Vc[i]);
						x = x - Vn[i];
					} else
						i++;
				}
				System.out.println();
			}
		}
	}

